﻿namespace Devonline.Entity;

/// <summary>
/// 货品类别
/// </summary>
/// <typeparam name="TKey"></typeparam>
[DisplayName("采购订单")]
public class PurchaseOrderViewModel : PurchaseOrderViewModel<string>, IViewModel, IEntitySet
{
    /// <summary>
    /// 供应商
    /// </summary>
    public virtual SupplierViewModel? Supplier { get; set; }
    /// <summary>
    /// 采购订单明细
    /// </summary>
    public virtual ICollection<PurchaseOrderDetailViewModel>? Details { get; set; }
    /// <summary>
    /// 采购订单支付记录
    /// </summary>
    public virtual ICollection<PurchaseOrderPaymentRecord>? PaymentRecords { get; set; }
}

/// <summary>
/// 货品类别
/// </summary>
/// <typeparam name="TKey"></typeparam>
[DisplayName("采购订单")]
public abstract class PurchaseOrderViewModel<TKey> : ViewModel<TKey>, IViewModel<TKey>, IEntitySet<TKey> where TKey : IConvertible
{
    /// <summary>
    /// 供应商
    /// </summary>
    [MaxLength(36), DisplayName("供应商"), Required, Excel]
    public virtual string SupplierId { get; set; } = null!;
    /// <summary>
    /// 订单号
    /// </summary>
    [Required, MaxLength(36), DisplayName("订单号")]
    public virtual string OrderNumber { get; set; } = null!;
    /// <summary>
    /// 订单金额
    /// </summary>
    [DisplayName("订单金额"), Excel]
    public virtual decimal Amount { get; set; }
}

/// <summary>
/// 采购订单明细
/// </summary>
[DisplayName("采购订单明细")]
public class PurchaseOrderDetailViewModel : PurchaseOrderDetailViewModel<string>, IViewModel, IEntitySet
{
    /// <summary>
    /// 采购订单
    /// </summary>
    public virtual PurchaseOrderViewModel? Order { get; set; }
    /// <summary>
    /// 货品
    /// </summary>
    public virtual ProductViewModel? Product { get; set; }
}

/// <summary>
/// 采购订单明细
/// </summary>
[DisplayName("采购订单明细")]
public abstract class PurchaseOrderDetailViewModel<TKey> : ViewModel<TKey>, IViewModel<TKey>, IEntitySet<TKey> where TKey : IConvertible
{
    /// <summary>
    /// 采购订单编号
    /// </summary>
    [Required, MaxLength(36), DisplayName("采购订单编号"), Excel]
    public virtual string OrderId { get; set; } = null!;
    /// <summary>
    /// 货品编号
    /// </summary>
    [Required, MaxLength(36), DisplayName("货品编号")]
    public virtual string ProductId { get; set; } = null!;
    /// <summary>
    /// 货品品质
    /// </summary>
    [MaxLength(128), DisplayName("货品品质"), Excel]
    public virtual string? Quality { get; set; }
    /// <summary>
    /// 采购价
    /// </summary>
    [DisplayName("采购价"), Excel]
    public virtual decimal Price { get; set; }
    /// <summary>
    /// 数量
    /// </summary>
    [DisplayName("数量"), Excel]
    public virtual decimal Count { get; set; }
}